/* Copyright (c) 2009, Enric Rodriguez (enrodri86@gmail.com)
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 	- Redistributions of source code must retain the above copyright
 * 	notice,	this list of conditions and the following disclaimer.
 * 	- Redistributions in binary form must reproduce the above copyright
 * 	notice, this list of conditions and the following disclaimer in the
 * 	documentation and/or other materials provided with the distribution.
 * 	- Neither the name of the <ORGANIZATION> nor the names of its
 * 	contributors may be used to endorse or promote products derived from
 * 	this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package es.enrodri86.mmo.auth.shared;

import java.io.Serializable;

/**
 * This class represents a Game Server. The status constants are defined as a
 * usual case. They might not be used. You can specify your own status by using
 * any integer value.
 *
 * An issue to solve is that there might be different cluster servers for each
 * game servers. In this case you can configure load balancing making use of
 * DNS, or use a special dispatcher software.
 *
 * @author enrodri86
 */
public class GameServer implements Serializable{

	private static final long serialVersionUID = -1858213419795220482L;

	private String name;

	private String url;

	private String host;

	private int port;

	private String description;

	private int status;

	private String id;

	// Do not use 0 as a Status.
	public static final int STATUS_DOWN = -3;
	public static final int STATUS_RELOADING = -2;
	public static final int STATUS_PAUSED = -1;
	public static final int STATUS_BUSY = 1;
	public static final int STATUS_HEAVY = 2;
	public static final int STATUS_NORMAL = 3;
	public static final int STATUS_LIGHT = 4;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public GameServer(String name, String description, int status) {
		this.name = name; this.description = description; this.status = status;
	}
	public GameServer() {}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getHost() {
		return host;
	}
	public void setHost(String host) {
		this.host = host;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getPort() {
		return port;
	}
	public void setPort(int port) {
		this.port = port;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}

	@Override
	public String toString() {
		String statuscolor = "black";
		String statusname = "-";
		switch(status){
		case STATUS_BUSY:
			statuscolor = "black";
			statusname = "BUSY";
			break;
		case STATUS_DOWN:
			statuscolor = "black";
			statusname = "DOWN";
			break;
		case STATUS_HEAVY:
			statuscolor = "red";
			statusname = "HEAVY";
			break;
		case STATUS_LIGHT:
			statuscolor = "blue";
			statusname = "LIGHT";
			break;
		case STATUS_NORMAL:
			statuscolor = "green";
			statusname = "GREAT";
			break;
		case STATUS_PAUSED:
			statuscolor = "black";
			statusname = "PAUSED";
			break;
		case STATUS_RELOADING:
			statuscolor = "yellow";
			statusname = "RELOAD";
			break;
		}


		return "<html><font color=\""+statuscolor+"\">"+name+" [ "+statusname+" ]</font></html>";
	}

}
